package com.xiaotu.spider;

import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * @类名 FinsishedSpider
 * @日期 2017年6月2日
 * @作者 高海军
 * @功能 爬虫任务实现类：爬取数据完成后，执行某些操作
 */
public class FinsishedSpider extends Spider
{
	private Runnable runnable;
	
	public FinsishedSpider(PageProcessor pageProcessor,Runnable runnable)
	{
		super(pageProcessor);
		this.runnable = runnable;
	}
	
	public static Spider create(PageProcessor pageProcessor,Runnable runnable)
	{
		return new FinsishedSpider(pageProcessor,runnable);
	}
	
	@Override
	public void close()
	{
		super.close();
		if (this.runnable != null)
			runnable.run();
	}
}
